from tracking.views import UpdateFuturesView
from tracking.views import UpdateForexView, DeleteTrackRecordForexView
from tracking.views import CreateTrackRecordForexView, CreateTrackRecordFuturesView
from tracking.views import DeleteTrackRecordFuturesView
from django.contrib.auth.decorators import login_required, permission_required
from jrcshared.models import JrcPermission
from django.conf.urls.defaults import patterns

urlpatterns = patterns(
    "tracking.views"
    , (r"^$", "list_tracks_by_month")
#    , (r"^futures/$", login_required(ListTrackRecordFutures.as_view()))
    , (r"^futures/(?P<pk>\d+)/$", login_required(UpdateFuturesView.as_view()))
    , (r"^futures/(?P<pk>\d+)/delete/$", login_required(DeleteTrackRecordFuturesView.as_view()))
    , (r"^futures/importfile/$", "import_futures_from_file")
    
    # Display form to enter text (Futures)
    , (r"^futures/importtext/$", "import_text", {"tracktype": "futures"})
    # Parse text and confirm import if no errors (Futures)
    , (r"^futures/parsetext/$", "parse_text", {"tracktype": "futures"})

    # Display form to enter text (Forex)
    , (r"^forex/importtext/$", "import_text", {"tracktype": "forex"})
    # Parse text and confirm import if no errors (Forex)
    , (r"^forex/parsetext/$", "parse_text", {"tracktype": "forex"})

    , (r"^(?P<track_type>futures|forex)/$", "list_tracks_by_month")
    
    # Ajax loading
    , (r"^get(?P<track_type>futures|forex)/$", "get_list_tracks_by_month")

    , (r"^create/forex/$", permission_required(JrcPermission.PET_CHANGE, "/accounts/denied/")( CreateTrackRecordForexView.as_view()) )
    , (r"^create/futures/$", permission_required(JrcPermission.PET_CHANGE, "/accounts/denied/")( CreateTrackRecordFuturesView.as_view()) )
    
    , (r"^getcreate/futures/$", "get_create_futures")
    , (r"^getcreate/forex/$", "get_create_forex")

    , (r"^forex/importfile/$", "import_forex_from_file")
    , (r"^forex/(?P<pk>\d+)/$", login_required(UpdateForexView.as_view()))
    , (r"^forex/(?P<pk>\d+)/delete/$", login_required(DeleteTrackRecordForexView.as_view()))

)
